# list列表删除元素
# del 根据索引值删除元素
lang = ["Python", "C++", "Java", "PHP", "Ruby", "MATLAB"]
# 使用正数索引
del lang[2]
print("del lang[2] =", lang)

# 使用负数索引
del lang[-2]
print("del lang[-2] =", lang)

print()

# 使用 del 删除一段连续的元素
lang = ["Python", "C++", "Java", "PHP", "Ruby", "MATLAB"]
del lang[1: 4]
print("del lang[1: 4] =", lang)

lang.extend(["SQL", "C#", "Go"])
del lang[-5: -2]
print("del lang[-5: -2] =", lang)

print()

# pop() 根据索引值删除元素
nums = [40, 36, 89, 2, 36, 100, 7]
nums.pop(3)
print("nums.pop(3) =", nums)
nums.pop()
print("nums.pop() =", nums)

print()

# remove() 根据元素值进行删除
nums = [40, 36, 89, 2, 36, 100, 7]
# 第一次删除 36
nums.remove(36)
print("nums.remove(36) =", nums)
# 第二次删除 36
nums.remove(36)
print("nums.remove(36) =", nums)
# 删除78
#nums.remove(78)
#print("nums.remove(78) =", nums)

# clear() 删除列表所有元素
url = list("http://c.biancheng.net/python/")
print("clear前：", url)
url.clear()
print("clear后：", url)
